package com.uziot.activiti6.controller.editor;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;

import io.swagger.annotations.Api;
import org.activiti.engine.ActivitiException;
import org.apache.commons.io.IOUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @author shidt
 * @version V1.0
 * @className ModelSaveRestResource
 * @date 2021-02-26 10:38:41
 * @description
 */

@Api(tags = "编辑器-中文国际化")
@RestController
@RequestMapping(value = "/service")
public class StencilsetRestResource {

    @GetMapping(value = "/editor/stencilset", produces = "application/json;charset=utf-8")
    public @ResponseBody
    String getStencilset() {
        InputStream stencilsetStream = this.getClass().getClassLoader()
                .getResourceAsStream("stencilset.json");
        try {
            assert stencilsetStream != null;
            return IOUtils.toString(stencilsetStream, StandardCharsets.UTF_8);
        } catch (Exception e) {
            throw new ActivitiException("Error while loading stencil set", e);
        }
    }
}
